package com.xoa.controller.party;


import com.xoa.model.party.GeneralSafetyUnitWithBLOBs;
import com.xoa.service.party.GeneralSafetyUnitService;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/sv1/generalsafetyunit")
public class GeneralSafetyUnitController {
    @Autowired
    private GeneralSafetyUnitService generalSafetyUnitService;

    /**
     * 可选择字段增加
     * @param generalSafetyUnitWithBLOBs
     * @return
     */
    @ResponseBody
    @RequestMapping("/insertSelective")
    public ToJson insertSelective(GeneralSafetyUnitWithBLOBs generalSafetyUnitWithBLOBs,
                                  String tbr, String lxdh, String tbsj ){
        //设置填表人、联系电话、报出日期
        generalSafetyUnitWithBLOBs.setFormHolder(tbr);
        generalSafetyUnitWithBLOBs.setContactNumber(lxdh);
        generalSafetyUnitWithBLOBs.setDateOfPublication(tbsj);
        return generalSafetyUnitService.insertSelective(generalSafetyUnitWithBLOBs);
    }

    /**
     * 根据id删除
     * @param generalSafetyUnitId
     * @return
     */
    @ResponseBody
    @RequestMapping("/deleteBygeneralSafetyUnitId")
    public ToJson deleteBygeneralSafetyUnitId(int generalSafetyUnitId){
        return generalSafetyUnitService.deleteBygeneralSafetyUnitId(generalSafetyUnitId);
    }

    /**
     * 修改
     * @param generalSafetyUnitWithBLOBs
     * @return
     */
    @ResponseBody
    @RequestMapping("/updataByPrimaryKeySelective")
    public ToJson updateByPrimaryKeySelective(GeneralSafetyUnitWithBLOBs generalSafetyUnitWithBLOBs, String tbr, String lxdh, String tbsj){
        //设置填表人、联系电话、报出日期
        generalSafetyUnitWithBLOBs.setFormHolder(tbr);
        generalSafetyUnitWithBLOBs.setContactNumber(lxdh);
        generalSafetyUnitWithBLOBs.setDateOfPublication(tbsj);
        return generalSafetyUnitService.updateByPrimaryKeySelective(generalSafetyUnitWithBLOBs);
    }

    /**
     * 根据id查询
     * @param generalSafetyUnitId
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectBygeneralSafetyUnitId")
    public ToJson selectBygeneralSafetyUnitId(int generalSafetyUnitId){
        return generalSafetyUnitService.selectBygeneralSafetyUnitId(generalSafetyUnitId);
    }

    /**
     * 分页条件查询
     * @param page
     * @param pageSize
     * @param useFlag
     * @param generalSafetyUnitWithBLOBs
     * @return
     */
    @ResponseBody
    @RequestMapping("/selectSelective")
        public ToJson selectSelective(Integer page, Integer pageSize, boolean useFlag,
                                      GeneralSafetyUnitWithBLOBs generalSafetyUnitWithBLOBs){
        return generalSafetyUnitService.selectSelective(page,pageSize,useFlag,generalSafetyUnitWithBLOBs);
    }
}
